package com.seven.dao;

import java.util.List;

import com.seven.entity.Users;

//普通用户的dao
public class AUsersDao extends BaseDao {
	/**
	 * 用户的增加
	 */
	public int addUsers(Users users) {
		String sql = "insert into users(users_name,users_username,users_password,users_score)values(?,?,?,?)";
		Object[] ob = {users.getUsers_name(),users.getUsers_username(),users.getUsers_password(),users.getUsers_score()};
		int n = super.update(sql, ob);
		return n;

	}

	/**
	 * 用户的更改(对密码和积分)
	 */
	public int updateUsers(Users users) {
		String sql = "update users set users_name = ?,users_username = ?,users_password = ?,users_score = ? where user_id=?";
		Object[] ob = {users.getUsers_name(),users.getUsers_username(),users.getUsers_password(),users.getUsers_score(),users.getUsers_id()};
		int n = super.update(sql, ob);
		return n;

	}

	/**
	 * 用户的查询(查询所有用户)
	 */
	public List<Users> selectAllUsers() {
		
		String sql = "select * from users";
		return super.query2(sql, Users.class);
		
		
	}

	/**
	 * 用户的查询(通过账号查询)
	 */
	public List<Users> selectByUsers_username(Users users) {
		String sql = "select * from users where users_username=? and users_password=?";
		Object[] ob = {users.getUsers_username(),users.getUsers_password()};
		return super.query2(sql, Users.class, ob);
	}

//	public static void main(String[] args) {
//		Users users = new Users();
//		users.setUsers_username("13911111111");
//		users.setUsers_password("123");
//		List<Users> usersList = new UsersDao().selectByUsers_username(users);
//		System.out.println(usersList.get(0));
//	}

}
